<template>
  <div>
<h2>房号修改</h2>
<table border="1">
      
      <tr>
        <td>名称</td>
        <td>
          <input type="text" v-model="state.name">
        </td>
      </tr>
      <tr>
        <td>价格</td>
        <td>
          <input type="text" v-model="state.price">
        </td>
      </tr>
      <tr>
        <td>面积</td>
        <td>
          <input type="text"  v-model="state.size">
        </td>
      </tr>
     
      <tr>
        <td></td>
        <td>
          <input type="button" @click="add" value="修改">
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { reactive,toRefs,onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';
let route=useRoute();
let router=useRouter();
let data=reactive({
  state:{
  id:'',
  num: '',
  name: '',
  price: '',
  size: '',
  address: '',
  sdate: '',
  state: ''
  }
})
let {state}=toRefs(data)
onMounted(()=>{
  checkall();
})
//反填
const checkall=()=>{
 let obj={
     
 }
 axios({
  url:'',
  method:'',
  params:obj
 })
 .then(res=>{
  route.query=res.data.data
 })
 .catch(err=>{

 })
}
function add()
{
  let obj={
  "id":route.query.id,
  "num": state.value.num,
  "name": state.value.name,
  "price": state.value.price,
  "size": state.value.size,
  "address": state.value.address,
  "sdate": state.value.sdate,
  "state": 0
  }
  
  axios({
    url:'/api/Room/Upda',
    method:'post',
    data:obj
  })
  .then(res=>{
 if(res.data.data==1)
 {
  alert("修改成功")
  router.push("../nshow")
 }
 else
 {
  alert("修改失败")
 }
  })
  .catch(err=>{

  })
}
</script>

<style scoped>

</style>